package com.niuwa.p2p.action.interview;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;

import com.niuwa.p2p.action.JsonAction;
import com.niuwa.p2p.core.mvc.entity.JsonResult;
import com.niuwa.p2p.entity.channel.LoanRelativeFile;
import com.niuwa.p2p.service.channel.ILoanRelativeFileService;

public class InterviewFileUploadAction extends JsonAction{
	/**
	 * 
	 */
	private static final long serialVersionUID = -5607995593504781971L;
	@Autowired
	private ILoanRelativeFileService loanRealtiveFileService;
	
	private String projectNo;
	
	private String FileID;
	
	private String FileName;
	/**
	 * 签署协议文件列表显示
	 * 
	 * @return
	 */
	@Action(value = "listLoanRealtiveFile")
	public String listLoanRealtiveFile() {
		List<LoanRelativeFile> loanRelativeFiles = loanRealtiveFileService
				.searchLoanRealtiveFileService(projectNo);
		// 设置返回
		setObjectReSult(loanRelativeFiles);
		return NONE;
	}
	/**
	 * 保存签署协议文件记录到本地数据库
	 * 
	 * @return
	 */
	@Action("saveLoanRealtiveFile")
	public String saveLoanRealtiveFile() {
		// 从session中那user
		// 得到当前用户
		String message = "文件上传失败，请重试";
		if (!projectNo.isEmpty()) {
			loanRealtiveFileService.saveLoanRealtiveFile(FileID ,FileName,
					projectNo);
			message = "你已成功上传文件";
		}
		JsonResult result = new JsonResult();
		result.setMsg(message);
		this.setResult(result);
		return NONE;
	}

	public String getProjectNo() {
		return projectNo;
	}
	public void setProjectNo(String projectNo) {
		this.projectNo = projectNo;
	}
	public String getFileID() {
		return FileID;
	}
	public void setFileID(String fileID) {
		FileID = fileID;
	}
	public String getFileName() {
		return FileName;
	}
	public void setFileName(String fileName) {
		FileName = fileName;
	}
}
